package com.lin.lazybone.adapter;

import android.content.Context;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lin.lazybone.R;
import com.lin.lazybone.entity.CourierData;
import com.lin.lazybone.entity.DelType;
import com.lin.lazybone.fragment.OrderFragment;

import java.util.List;

/**
 * Created by mr.lin on 2017/10/22.
 */

public class DialogLVAdapter extends BaseAdapter
{
    private Context mContext;
    private List<DelType> mList;

    public DialogLVAdapter(Context mContext, List<DelType> mList)
    {
        this.mContext = mContext;
        this.mList = mList;
    }


    @Override
    public int getCount()
    {
        return mList.size();
    }

    @Override
    public Object getItem(int position)
    {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position)
    {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        ViewHolder viewHolder = null;
        //第一次加载
        if(convertView == null){
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.dialog_lv_item,null);
            viewHolder.dialog_image = (ImageView) convertView.findViewById(R.id.dialog_image);
            //设置缓存
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }

        //设置数据
        DelType delType = mList.get(position);
        viewHolder.dialog_image.setBackgroundResource(delType.getImageID());
        return convertView;
    }

    class ViewHolder{
        private ImageView dialog_image;
    }
}
